<?php

class City_Model extends CI_Model {

    private $dbKai;

    public function __construct() {
        parent::__construct();
        $this->dbKai = $this->load->database('kai', TRUE);
    }

    public function getCity($whr, $pagelimit,$offset) {
        $sql = "SELECT tb_city.*, tb_province.* 
                FROM tb_city 
                LEFT JOIN tb_province ON tb_city.provinceid = tb_province.provinceid
                $whr
                ORDER BY tb_city.cityname ASC 
                LIMIT $pagelimit OFFSET $offset";
        $resultSet = $this->dbKai->query($sql);
        return $resultSet;
    }
    
    public function getCityAll($whr) {
        $sql = "SELECT tb_city.*, tb_province.* 
                FROM tb_city 
                LEFT JOIN tb_province ON tb_city.provinceid = tb_province.provinceid
                $whr
                ORDER BY tb_city.cityname ASC";
        $resultSet = $this->dbKai->query($sql);
        return $resultSet;
    }

}

?>
